#include <iostream>

using namespace std;

//关系运算符重载作用:重载关系运算符，可以让两个自定义类型对象进行对比操作
class Person {
public:
    string name;
    int age;

    Person() {}

    Person(const string &name, const int &age) : name(name), age(age) {}

    //重载==号
    bool operator==(Person &person) {
        if (this->age == person.age && this->name == person.name) {
            return true;
        } else {
            return false;
        }
    }

    //重载!=号
    bool operator!=(Person &person) {
        if (this->age != person.age || this->name != person.name) {
            return true;
        } else {
            return false;
        }
    }
};

void test1() {
    Person person1("tom", 18);
    Person person2("tom", 18);
    if (person1 == person2) {
        cout << "p1=p2" << endl;
    } else {
        cout << "p1!=p2" << endl;
    }
    if (person1 != person2) {
        cout << "p1!=p2" << endl;
    } else {
        cout << "p1=p2" << endl;
    }
};

int main() {
    test1();
    return 0;
}

